package com.kechen.client.controller;

import com.kechen.client.fegin.Myfegin;
import com.kechen.client.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 0xHertz
 * @Date: 2022/11/7 0007 14:17
 * @Description:
 **/
@RestController
public class TestFeginController {

    @Autowired
    private Myfegin myfegin;

    /**
     * 测试feign调用
     * @return
     */
    @RequestMapping("/testFeign")
    public String testFeign() {
        //调用feign接口方法
        String str = myfegin.index();
        return str;
    }

    // 参数传递的情况
    @RequestMapping("/user/{id}")
    public User findById(@PathVariable Integer id){
        return myfegin.findById(id);
    }

    @RequestMapping("/getUser")
    public User getUser(@RequestParam Integer id, @RequestParam String name){
        return myfegin.getUser(id,name);
    }

    @RequestMapping("/save")            // 会自动转换为POST请求  405
    public User save(User customer){
        return myfegin.save(customer);
    }
}
